package com.init.bootframe.config.interceptor;

import com.init.bootframe.config.Filter.BodyReaderHttpServletRequestWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class InMessageInterceptor implements HandlerInterceptor {
    private static Logger logger = LoggerFactory.getLogger(InMessageInterceptor.class);
    /**
     * 拦截请求，在controller调用之前
     * @param request
     * @param response
     * @param handler
     * @return
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        String message = BodyReaderHttpServletRequestWrapper.getBody();
        try {
            logger.info("拦截器入参："+ message);
            String servletPath = request.getServletPath();
            System.out.println("拦截器请求路径:"+servletPath);
            // TODO IP 白名单 以及 token检验
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }




}
